package Unite;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class UnitTest extends TestCase {
	private Unit _archer;
	private Unit _chevalier;
	private Unit _toruk;
	private Unit _guerrier;

	@Before
	public void setUp() {
		_archer = FactoryUnit.CreateUnit(Unit.ARCHER, new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), 0);
		_chevalier = FactoryUnit.CreateUnit(Unit.CHEVALIER, new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), 0);
		_toruk = FactoryUnit.CreateUnit(Unit.TORUK, new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), 0);
		_guerrier = FactoryUnit.CreateUnit(Unit.GUERRIER, new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), 0);

	}

	@After
	public void tearDown() {
		_archer = null;
		_chevalier = null;
		_toruk = null;
		_guerrier = null;
	}

   @Test
   public void testGetPower() {
      assertTrue(_toruk.getPower() == 5);
      assertTrue(_archer.getPower() == 2);
      assertTrue(_guerrier.getPower() == 1.5);
      assertTrue(_chevalier.getPower() == 3);
   }

   @Test
   public void testGetWeight() {
      assertTrue(_toruk.getWeight() == 5);
      assertTrue(_archer.getWeight() == 1.5);
      assertTrue(_guerrier.getWeight() == 2.5);
      assertTrue(_chevalier.getWeight() == 3);
   }

   @Test
   public void c() {
      assertTrue(_toruk.getId() % 4 == 2);
      assertTrue(_archer.getId() % 4  == 0);
      assertTrue(_guerrier.getId() % 4  == 3);
      assertTrue(_chevalier.getId() % 4  == 1);
   }

   @Test
   public void testGetAttributeMap() {
      assertTrue(_toruk.getAttributes().equals(new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)));
      assertTrue(_archer.getAttributes().equals(new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)));
      assertTrue(_guerrier.getAttributes().equals(new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)));
      assertTrue(_chevalier.getAttributes().equals(new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)));
   }

   @Test
   public void testSetAttributeMap() {
      _chevalier.setAttributes(new AttributeMap(5,5,5,5,5,5,5,5,5,5,5,5,5,0));
      assertTrue(_chevalier.getAttributes().equals(new AttributeMap(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0)));
   }

   @Test
   public void testGetClasseId() {
      assertTrue(_chevalier.getClasseId() == Unit.CHEVALIER);
      assertTrue(_archer.getClasseId() == Unit.ARCHER);
      assertTrue(_guerrier.getClasseId() == Unit.GUERRIER);
      assertTrue(_toruk.getClasseId() == Unit.TORUK);
   }
}
